<extend name="Public/base" />
<block name="main">
    <fieldset class="layui-elem-field">
        <legend>推送管理 - 请求队列列表</legend>
         <!--搜索部分-->
         <div class="layui-field-box">
            <form class="layui-form" action="/admin/push/queuelist" method="POST">
                <div class="layui-form-item">
                    <label class="layui-form-label">分类</label>
                    <div class="layui-input-block">
                            <span id="companyname"><input type="radio" name="type" value="1" title="商户" checked></span>
                            <span class="myfenlei"><input type="radio" name="type" value="2" title="消息内容" ></span>
                            <span class="myfenlei"><input type="radio" name="type" value="3" title="CID" ></span>
                            <span id="receivetime"><input type="radio" name="type" value="4"  title="请求时间"></span>
                            <span id="dealstatus"><input type="radio" name="type" value="5" title="处理状态"></span>
                    </div>
                </div>
                 <div class="layui-form-item" id="company">
                    <label class="layui-form-label">商户名称</label>
                    <div class="layui-input-block">
                        <select name="c_id" lay-verify="">
                        <option value="0" selected>请选择</option>
                        <volist name="clist" id="vo">
                        <option value="{$vo['id']}">{$vo['company_name']}</option>
                        </volist>
                        </select>
                    </div>
                </div>                 
                 <div class="layui-form-item" id="time" style="display:none;">
                    <label class="layui-form-label">请选择时间</label>
                    <div class="layui-input-block">
                         <input type="text" name="mydate"  lay-verify="required"  class="layui-input" style="width:100px;" onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD'})">
                    </div>
                </div>
                <div class="layui-form-item" id="status" style="display:none;">
                    <label class="layui-form-label">处理状态</label>
                    <div class="layui-input-block">
                        <select name="status" lay-verify="">
                        <option value="-1" selected>请选择</option>
                        <option value="0" selected>未处理</option>
                        <option value="1">处理成功</option>
                        <option value="2">处理失败</option>
                        </select>
                    </div>
                </div>                                 
                <div class="layui-form-item" id="keyword" style="display:none;">
                    <label class="layui-form-label">关键字</label>
                    <div class="layui-input-block">
                        <input type="text"  name="keyword" maxlength="30" class="layui-input">
                    </div>
                </div>                
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <input type="submit" class="layui-btn" name="submit" value="&nbsp;提&nbsp;&nbsp;交&nbsp;">
                    </div>
                </div>
            </form>
        </div>
         <!--end-->      
        <div class="layui-field-box">
            <table class="layui-table" lay-even>
                <thead>
                <tr>
                    <th>商户ID</th>
                    <th>消息内容</th>
                    <th>CID</th>
                    <th>发送类型</th>
                    <th>发送时间</th>
                    <th>接收时间</th>
                    <th>处理状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <volist name="list" id="vo">
                    <tr>
                        <td>{$vo['c_id']}</td>
                        <td>{$vo['content']}</td>
                        <td>{$vo['cid']}</td>
                        <td>{:($vo['type'] == 1)?'定时':'即时'}</td>
                        <td>{:($vo['type'] == 1)?date('Y-m-d H:i:s',$vo['timing']):''}</td>
                        <td>{:date('Y-m-d H:i:s',$vo['receive_time'])}</td>
                        <td><if condition="$vo['status'] == 0">未处理</if> <if condition="$vo['status'] == 1">处理成功</if> <if condition="$vo['status'] == 2">处理失败</if></td>
                        <td>
                        <if condition="$vo['status'] == 2">
                        <span data-url="{:U('qhandpush')}" data-id="{$vo['id']}" class="layui-btn layui-btn-normal">手动发送</span>
                        </if>
                        </td>            
                    </tr>
                </volist>
                </tbody>
            </table>
        </div>
    </fieldset>
</block>
<block name="myScript">
 <script type="text/javascript" src="__PUBLIC__/layui/lay/modules/laydate.js"></script>   
 <script language="javascript" type="text/javascript">
         layui.use('form', function(){
                var form = layui.form();                                   
          });   
</script>     
<script language="javascript" type="text/javascript">
        $(document).ready(function(){
  			$("#companyname").click(function(){ 
 				$('#company').show(); 
                $('#time').hide();
                $('#status').hide();
                $('#keyword').hide();
           });        	
			$("#receivetime").click(function(){  
                $('#time').show();
                $('#status').hide();
                $('#keyword').hide();
                $('#company').hide();
           }); 
			$("#dealstatus").click(function(){  
                $('#status').show();
                $('#time').hide();
                $('#keyword').hide();
                $('#company').hide();
           });
 		   $(".myfenlei").click(function(){  
                $('#status').hide();
                $('#time').hide();
                $('#keyword').show();
                $('#company').hide();
           }); 
	       $('.layui-btn-normal').on('click', function () {
                    $.ajax({
                        type: "GET",
                        url: $(this).attr('data-url'),
                        data: {id:$(this).attr('data-id')},
                        success: function(msg){
                                 alert(msg);
                                 location.reload();
                        }
                    });
               
            });                                                      
         });             
</script>   
</block>